import express from 'express';
import {
  getStudents,
  getStudentById,
  createStudent,
  updateStudent,
  deleteStudent
} from '../controllers/studentController.js';
import { auth, hasPermission } from '../middleware/auth.js';

const router = express.Router();

// 受保护路由
// 学生管理路由
router.get('/', 
  auth, 
  hasPermission('read_students'), 
  getStudents);
router.get('/:id', 
  auth, 
  hasPermission('read_students'), 
  getStudentById);
router.post('/', 
  auth, 
  hasPermission('create_students'), 
  createStudent);
router.put('/:id', 
  auth, 
  hasPermission('update_students'), 
  updateStudent);
router.delete('/:id', 
  auth, 
  hasPermission('delete_students'), 
  deleteStudent);

export default router;